package com.dunqi.gpm.cangxi.WeekReport.WeekReport

import android.support.v7.widget.RecyclerView
import com.chad.library.adapter.base.BaseViewHolder

import com.dunqi.gpm.cangxi.R
import com.dunqi.gpm.cangxi.WeekReport.Model.WeekReport
import com.dunqi.gpm.cangxi.WeekReport.OnListFragmentInteractionListener
import com.dunqi.gpm.cangxi.common.base.RecyclerAdapter

/**
 * [RecyclerView.Adapter] that can display a [DummyItem] and makes a call to the
 * specified [OnListFragmentInteractionListener].
 * TODO: Replace the implementation with code for your list_photo type.
 */
class WeekReportRecyclerViewAdapter(mValues: List<WeekReport>, private val mListener: OnListFragmentInteractionListener?) :
        RecyclerAdapter<WeekReport>(R.layout.fragment_itemweekreport, mValues) {
    override fun convert(helper: BaseViewHolder?, item: WeekReport?) {
        helper?.setText(R.id.project_name, "${item?.projectName}") //项目名称
        helper?.setText(R.id.project_plan_week, "${item?.projectReportWeekly?.weeks}") //计划周次
        helper?.setText(R.id.project_plan_content, "${item?.planContext}") //计划内容
        helper?.setText(R.id.project_plan_report_content, "${item?.reportContext}") //报告内容

        var status = item?.projectReportWeekly?.status
        var statusStr: String? = null
        when (status) {
            0 -> statusStr = "未审核"
            -1 -> statusStr = "退回重报"
            1 -> statusStr = "待审核"
            2, 3 -> statusStr = "审核中"
            4 -> statusStr = "审批通过"
        }
        helper?.setText(R.id.project_plan_ischeked, statusStr) //是否审批
        helper?.setText(R.id.project_duty_units, "${item?.orgName}") //责任单位
        helper?.setText(R.id.project_superversion_units, "") //监理单位
        helper?.setText(R.id.project_implement_units, "") //施工单位
        helper?.setText(R.id.project_plan_writer, "${item?.createName}") //填报人
        helper?.setText(R.id.project_plan_write_time, "${item?.projectReportWeekly?.createTime}") //填报时间
        helper?.itemView?.setOnClickListener { _ ->
            mListener?.onListFragmentInteraction(item!!, myFlag)
        }
    }

    val myFlag = 3

}
